<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for src/FileUpload.vue</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../prettify.css" />
    <link rel="stylesheet" href="../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../index.html">all files</a> / <a href="index.html">src/</a> FileUpload.vue
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">10% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>3/30</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/18</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">16.67% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>1/6</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">6.9% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>2/29</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">// &lt;template&gt;
//   &lt;input type="file" name="fileUpload" @change="onFileChange"&gt;
// &lt;/template&gt;
//
// &lt;script type="text/babel"&gt;
export default {
  name: 'fileupload',
  props: {
    target: {
      type: String
    },
    action: {
      type: String
    }
  },
  data () {
    return {
      file: null
    }
  },
  methods: <span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" >{</span></span></span>
    emitter (event, data) {
<span class="cstat-no" title="statement not covered" >      t</span>his.$emit(event, data)
    },
    updateProgress (oEvent) {
<span class="cstat-no" title="statement not covered" >      l</span>et vm = this
<span class="cstat-no" title="statement not covered" >      if (oEvent.lengthComputable) {</span>
<span class="cstat-no" title="statement not covered" >        l</span>et percentComplete = Math.round(oEvent.loaded * 100 / oEvent.total)
<span class="cstat-no" title="statement not covered" >        v</span>m.emitter('progress', percentComplete)
      } else {
        // Unable to compute progress information since the total size is unknown
<span class="cstat-no" title="statement not covered" >        v</span>m.emitter('progress', false)
      }
    },
    onFileChange (e) {
<span class="cstat-no" title="statement not covered" >      l</span>et vm = this
&nbsp;
<span class="cstat-no" title="statement not covered" >      if (!this.target || this.target === '') {</span>
<span class="cstat-no" title="statement not covered" >        c</span>onsole.log('Please provide the target url')
      } else <span class="cstat-no" title="statement not covered" >if (!this.action || this.action === '') {</span>
<span class="cstat-no" title="statement not covered" >        c</span>onsole.log('Please provide file upload action ( POST / PUT )')
      } else <span class="cstat-no" title="statement not covered" >if (this.action !== 'POST' &amp;&amp; this.action !== 'PUT') {</span>
<span class="cstat-no" title="statement not covered" >        c</span>onsole.log('File upload component only allows POST and PUT Actions')
      } else {
<span class="cstat-no" title="statement not covered" >        l</span>et files = e.target.files || e.dataTransfer.files
&nbsp;
<span class="cstat-no" title="statement not covered" >        if (!files.length) {</span>
<span class="cstat-no" title="statement not covered" >          r</span>eturn
        };
&nbsp;
        /*global FormData XMLHttpRequest:true*/
        /*eslint no-undef: "error"*/
&nbsp;
<span class="cstat-no" title="statement not covered" >        t</span>his.file = files[0]
<span class="cstat-no" title="statement not covered" >        l</span>et formData = new FormData()
<span class="cstat-no" title="statement not covered" >        f</span>ormData.append('file', this.file)
&nbsp;
<span class="cstat-no" title="statement not covered" >        v</span>ar xhr = new XMLHttpRequest()
<span class="cstat-no" title="statement not covered" >        x</span>hr.open(this.action, this.target)
&nbsp;
<span class="cstat-no" title="statement not covered" >        x</span>hr.onloadstart = <span class="fstat-no" title="function not covered" >function (e) {</span>
<span class="cstat-no" title="statement not covered" >          v</span>m.emitter('start', e)
        }
<span class="cstat-no" title="statement not covered" >        x</span>hr.onloadend = <span class="fstat-no" title="function not covered" >function (e) {</span>
<span class="cstat-no" title="statement not covered" >          v</span>m.emitter('finish', e)
        }
<span class="cstat-no" title="statement not covered" >        x</span>hr.upload.onprogress = vm.updateProgress
<span class="cstat-no" title="statement not covered" >        x</span>hr.send(formData)
      }
    }
  }
}
// &lt;/script&gt;
/* generated by vue-loader */
&nbsp;
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 16 2017 12:37:38 GMT+0530 (IST)
</div>
</div>
<script src="../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../sorter.js"></script>
</body>
</html>
